import { computed } from "vue";
import { IUser } from "@/api/RequestIDL/userType";
import { useLocalStorage } from "@vueuse/core";

const labJson = useLocalStorage<string>("labinfo", "");
const labTypeJson = useLocalStorage<string>("labTypeinfo", "");
const userInfoJson = useLocalStorage<string>("userinfo", "");
const semesterJson = useLocalStorage<string>("semesterinfo", "");
// 用户信息
const userInfo = computed((): IUser => {
  return !!userInfoJson.value ? JSON.parse(userInfoJson.value) : {};
});
// 实验室信息
const labInfo = computed((): any => {
  return !!labJson.value ? JSON.parse(labJson.value) : {};
});
// 实验室类型信息
const labTypeInfo = computed((): any => {
  return !!labTypeJson.value ? JSON.parse(labTypeJson.value) : {};
});
// 当前学期
// 实验室类型信息
const semesterInfo = computed((): any => {
  return !!semesterJson.value ? JSON.parse(semesterJson.value) : {};
});

export {
  userInfo,
  userInfoJson,
  labTypeInfo,
  labInfo,
  labJson,
  labTypeJson,
  semesterJson,
  semesterInfo,
};
